package guet.dream.question;

import guet.dream.answer.Answer;
import guet.dream.category.Category;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

public class Question {
	private int id;
	private String title;
	private String content;
	private Timestamp createTime;
	private int viewCount;
	private int answerCount;
	private Set<Category> categories = new HashSet<Category>();
	private Set<Answer> answers = new HashSet<Answer>();
	
	public Question(){}
	
	public Question(int id, String title, String content) {
		super();
		this.id = id;
		this.title = title;
		this.content = content;
		

	}
	public Question(String title, String content) {
		this.title = title;
		this.content = content;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Timestamp getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Timestamp createTime) {
		this.createTime = createTime;
	}

	public int getViewCount() {
		return viewCount;
	}

	public void setViewCount(int viewCount) {
		this.viewCount = viewCount;
	}

	public int getAnswerCount() {
		return answerCount;
	}

	public void setAnswerCount(int answerCount) {
		this.answerCount = answerCount;
	}

	public Set<Category> getCategories() {
		return categories;
	}

	public void setCategories(Set<Category> categories) {
		this.categories = categories;
	}

	public Set<Answer> getAnswers() {
		return answers;
	}

	public void setAnswers(Set<Answer> answers) {
		this.answers = answers;
	}


	
	public void addCategory(Category category){
		if(category == null){
			throw new IllegalArgumentException("Null category:类别为空值!");
		}
		category.getQuestions().add(this);
		this.categories.add(category);
	}
	

}
